package com.yeung.exam;


import java.util.Arrays;
import java.util.Scanner;

/**
 * Created by zmt on 2016/12/22.
 */
public class 最幸福得男生 {
    static String getIndexAndLongest(String users, int k) {
    //        bgbbbgbggbgbg
        char[] us = users.toCharArray();
        int[] grilsMax = new int[us.length];
        Arrays.fill(grilsMax, 0);
        for (int i = 0; i < us.length; i++) {
            int sumGs = 0;
            //遇到男生才找
            if (us[i] == 'b') {
                //找左边
                for (int le = i - 1; le >= 0; le--) {
                    if (us[le] == 'g') sumGs++;
                    else break;//遇到男生 终止
                }
                //找右边

                for (int re = i + 1; re < us.length; re++) {
                    if (us[re] == 'g') sumGs++;
                    else break;//遇到男生
                }
            }
            grilsMax[i] = sumGs;
        }
        int maxManId = getMaxMan(grilsMax);
        int mans = groupMan(us, k);
        System.out.println(maxManId + " " + mans);
        return "";
    }

    public static int groupMan(char[] users, int k) {
        //每个数为起始位置计算一次
        int res[] = new int[users.length];
        int max = users.length;
        for (int ts = 0; ts < users.length; ts++) {
            int kc=k;
            int tail = ts;
            while (true) {
                int ind = (tail + max) % max;
                if (users[ind] != 'b') {
                    //女生,用掉一次机会
                    if (kc > 0) {
                        kc--;
                        tail++;
                    } else break;
                } else {
                    tail++;
                }
            }
            //最对完成, 计算男生的数量
            int bs = 0;
            for (int y = ts; y <= tail; y++) {
                int ind = (y + max) % max;
                if (users[ind] == 'b') bs++;
            }
            res[ts] = bs;
        }
        int reuslt = Integer.MIN_VALUE;
        for (int j = 0; j < res.length; j++) {
            if (res[j] > reuslt) reuslt = res[j];
        }
        return reuslt;

    }

    public static int getMaxMan(int[] arr) {
        int max = Integer.MIN_VALUE;
        int maxId = -1;
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] > max) {
                max = arr[i];
                maxId = i;
            }
        }
        return maxId;
    }

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        String res;

        String _users;
        int k = 0;
        try {
            _users = in.nextLine();
            k = Integer.parseInt(in.nextLine());
        } catch (Exception e) {
            _users = null;
        }

        res = getIndexAndLongest(_users, k);
        System.out.println(res);
    }
}